# __init__.py :初始化文件，创建flask应用
import datetime

from flask import Flask
from .views import blue
def create_app():
    # 创建flask应用并返回app
    app = Flask(__name__)
    # 注册蓝图
    app.register_blueprint(blueprint=blue)
    # session 配置
    print(app.config) # flask配置信息
    # <Config {
    # 'DEBUG': False, 'TESTING': False, 'PROPAGATE_EXCEPTIONS': None,
    # 'SECRET_KEY': None, 'SECRET_KEY_FALLBACKS': None,
    # 'PERMANENT_SESSION_LIFETIME': datetime.timedelta(days=31),
    # 'USE_X_SENDFILE': False, 'TRUSTED_HOSTS': None, 'SERVER_NAME': None,
    # 'APPLICATION_ROOT': '/', 'SESSION_COOKIE_NAME': 'session',
    # 'SESSION_COOKIE_DOMAIN': None, 'SESSION_COOKIE_PATH': None,
    # 'SESSION_COOKIE_HTTPONLY': True, 'SESSION_COOKIE_SECURE': False,
    # 'SESSION_COOKIE_PARTITIONED': False, 'SESSION_COOKIE_SAMESITE': None,
    # 'SESSION_REFRESH_EACH_REQUEST': True, 'MAX_CONTENT_LENGTH': None,
    # 'MAX_FORM_MEMORY_SIZE': 500000, 'MAX_FORM_PARTS': 1000,
    # 'SEND_FILE_MAX_AGE_DEFAULT': None, 'TRAP_BAD_REQUEST_ERRORS': None,
    # 'TRAP_HTTP_EXCEPTIONS': False, 'EXPLAIN_TEMPLATE_LOADING': False,
    # 'PREFERRED_URL_SCHEME': 'http', 'TEMPLATES_AUTO_RELOAD': None,
    # 'MAX_COOKIE_SIZE': 4093, 'PROVIDE_AUTOMATIC_OPTIONS': True}>
    app.config['SECRET_KEY'] = 'asdewq123'
    app.config['PERMANENT_SESSION_LIFETIME'] = datetime.timedelta(days=7)
    return app